package router

import (
	"benkendSystem/api/user_login"
	"benkendSystem/middleware"
	"benkendSystem/router/depart_router"
	"benkendSystem/router/menu_router"
	"benkendSystem/router/role_router"
	"benkendSystem/router/user_router"
	"github.com/gin-gonic/gin"
)

func Router() *gin.Engine {
	r := gin.Default()
	r.Use(middleware.Cors())
	r.Use(middleware.LoggerToDb())
	r.POST("/api/login", user_login.Login)
	api := r.Group("/api")
	{
		user_router.UserRouter(api)
		role_router.RoleRouter(api)
		menu_router.MenuRouter(api)
		depart_router.DepartRouter(api)
	}

	return r
}
